<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Documentation Compiler</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Documentation Compiler' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../inbuildn.html">Inbuild Modules</a></li><li><a href="index.html">supervisor</a></li><li><a href="index.html#7">Chapter 7: Extension Management</a></li><li><b>Documentation Compiler</b></li></ul></div>
<p class="purpose">To compile documentation from the textual syntax in an extension into a tree.</p>

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. </b>A single set of documentation, such as might be associated with a project,
a tool or an extension or kit, is represented by a <span class="extract"><span class="extract-syntax">compiled_documentation</span></span>
object. This section provides just three public functions, for the three
ways to make one of these.
</p>

<p class="commentary">We can compile either from a single one-off file:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="function-syntax">DocumentationCompiler::compile_from_file</span><span class="plain-syntax">(</span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">F</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inform_extension</span><span class="plain-syntax"> *</span><span class="identifier-syntax">associated_extension</span><span class="plain-syntax">, </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sitemap</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">TextFiles::write_file_contents</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">, </span><span class="identifier-syntax">F</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">        </span><a href="7-dc.html#SP2" class="function-link"><span class="function-syntax">DocumentationCompiler::compile_from_text</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">, </span><span class="identifier-syntax">associated_extension</span><span class="plain-syntax">, </span><span class="identifier-syntax">sitemap</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">cd</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>Or from a fragment of text, which happens when a single-file-format extension's
torn-off documentation is found:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="function-syntax">DocumentationCompiler::compile_from_text</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::compile_from_text</span></span>:<br/><a href="7-dc.html#SP1">&#167;1</a><br/>Extension Services - <a href="5-es.html#SP12">&#167;12</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">scrap</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inform_extension</span><span class="plain-syntax"> *</span><span class="identifier-syntax">associated_extension</span><span class="plain-syntax">, </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sitemap</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">SVEXPLAIN</span><span class="plain-syntax">(1, </span><span class="string-syntax">"(compiling documentation: %d chars)\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">scrap</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax"> = </span><a href="7-dc.html#SP11" class="function-link"><span class="function-syntax">DocumentationCompiler::new_cd</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">associated_extension</span><span class="plain-syntax">, </span><span class="identifier-syntax">sitemap</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">compiled_from_extension_scrap</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">vol</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FIRST_IN_LINKED_LIST</span><span class="plain-syntax">(</span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">volumes</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">cd_pageset</span><span class="plain-syntax"> *</span><span class="identifier-syntax">page</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FIRST_IN_LINKED_LIST</span><span class="plain-syntax">(</span><span class="reserved-syntax">cd_pageset</span><span class="plain-syntax">, </span><span class="identifier-syntax">vol</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">pagesets</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">page</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">nonfile_content</span><span class="plain-syntax"> = </span><span class="identifier-syntax">scrap</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><a href="7-dc.html#SP21" class="function-link"><span class="function-syntax">DocumentationCompiler::compile_inner</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">cd</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>Or from a path to a directory holding what may be multiple Markdown files and
other resources, which is what happens when compiling the Inform manuals, or
the documentation for a directory-format extension.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="function-syntax">DocumentationCompiler::compile_from_path</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::compile_from_path</span></span>:<br/>Extension Services - <a href="5-es.html#SP14_1">&#167;14.1</a><br/>The Mini-Website - <a href="7-tm.html#SP7_1_1">&#167;7.1.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">pathname</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inform_extension</span><span class="plain-syntax"> *</span><span class="identifier-syntax">associated_extension</span><span class="plain-syntax">, </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sitemap</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax"> = </span><a href="7-dc.html#SP11" class="function-link"><span class="function-syntax">DocumentationCompiler::new_cd</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="identifier-syntax">associated_extension</span><span class="plain-syntax">, </span><span class="identifier-syntax">sitemap</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="7-dc.html#SP21" class="function-link"><span class="function-syntax">DocumentationCompiler::compile_inner</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">cd</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b>Now to take a look inside:
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="constant-syntax">NO_CD_INDEXES</span><span class="plain-syntax"> </span><span class="constant-syntax">4</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">ALPHABETICAL_EG_INDEX</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">NUMERICAL_EG_INDEX</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">THEMATIC_EG_INDEX</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">GENERAL_INDEX</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">title</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">inform_extension</span><span class="plain-syntax"> *</span><span class="identifier-syntax">associated_extension</span><span class="plain-syntax">; </span><span class="comment-syntax"> if an extension</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">inform_extension</span><span class="plain-syntax"> *</span><span class="identifier-syntax">within_extension</span><span class="plain-syntax">; </span><span class="comment-syntax"> if a kit inside an extension</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">pathname</span><span class="plain-syntax"> *</span><span class="identifier-syntax">domain</span><span class="plain-syntax">; </span><span class="comment-syntax"> where the documentation source is</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">source_files</span><span class="plain-syntax">; </span><span class="comment-syntax"> of </span><span class="extract"><span class="extract-syntax">cd_source_file</span></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">layout_errors</span><span class="plain-syntax">; </span><span class="comment-syntax"> of </span><span class="extract"><span class="extract-syntax">cd_layout_error</span></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">images</span><span class="plain-syntax">; </span><span class="comment-syntax"> of </span><span class="extract"><span class="extract-syntax">cd_image</span></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">images_URL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">compiled_from_extension_scrap</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">volumes</span><span class="plain-syntax">; </span><span class="comment-syntax"> of </span><span class="extract"><span class="extract-syntax">cd_volume</span></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">contents_URL_pattern</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">duplex_contents_page</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">xrefs_file_pattern</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">manifest_file_pattern</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">markdown_content</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">md_links_dictionary</span><span class="plain-syntax"> *</span><span class="identifier-syntax">link_references</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">empty</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">examples</span><span class="plain-syntax">; </span><span class="comment-syntax"> of </span><span class="extract"><span class="extract-syntax">IFM_example</span></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">example_URL_pattern</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">examples_lettered</span><span class="plain-syntax">; </span><span class="comment-syntax"> the alternative being, numbered</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cases</span><span class="plain-syntax">; </span><span class="comment-syntax"> of </span><span class="extract"><span class="extract-syntax">satellite_test_case</span></span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">include_index</span><span class="plain-syntax">[</span><span class="constant-syntax">NO_CD_INDEXES</span><span class="plain-syntax">];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">index_title</span><span class="plain-syntax">[</span><span class="constant-syntax">NO_CD_INDEXES</span><span class="plain-syntax">];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">index_URL_pattern</span><span class="plain-syntax">[</span><span class="constant-syntax">NO_CD_INDEXES</span><span class="plain-syntax">];</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">cd_indexing_data</span><span class="plain-syntax"> </span><span class="identifier-syntax">id</span><span class="plain-syntax">; </span><span class="comment-syntax"> for indexing the volumes in this cd</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure compiled_documentation is accessed in 2/wrk, 2/edt, 2/cps, 2/rqr, 2/jm, 3/bg, 3/is, 4/ebm, 4/km, 4/lm, 4/pm, 4/pbm, 4/pfm, 4/tm, 5/es, 5/ks, 5/ls, 5/ps2, 6/inc, 7/tm, 7/eip, 7/ti, 7/tc, 7/dr, 7/im, 7/mrp, 7/id, 7/it, 7/il, 7/imn, 7/gi, 7/ei and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>"Source files" are individual files of Markdown content which are collectively
read to compile the volumes of documentation.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">cd_source_file</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">leafname</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">as_filename</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">used</span><span class="plain-syntax">; </span><span class="comment-syntax"> did the layout file for this cd account for this file?</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">cd_source_file</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure cd_source_file is accessed in 7/dr and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b>A cd contains one or more "volumes". For something simple like an extension,
there will usually just be one volume, with the same title as the whole cd.
For the Inform manual built in to the apps, there will be two volumes,
"Writing with Inform" and "The Recipe Book".
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">title</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">label</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">home_URL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">source_files</span><span class="plain-syntax">; </span><span class="comment-syntax"> Markdown source leafnames</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pagesets</span><span class="plain-syntax">; </span><span class="comment-syntax"> of </span><span class="extract"><span class="extract-syntax">cd_pageset</span></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">volume_item</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="function-syntax">DocumentationCompiler::add_volume</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::add_volume</span></span>:<br/><a href="7-dc.html#SP11">&#167;11</a>, <a href="7-dc.html#SP12_1">&#167;12.1</a>, <a href="7-dc.html#SP12_2">&#167;12.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">title</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">label</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">home_URL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">vol</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">vol</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">title</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">title</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">vol</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">label</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">label</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">vol</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">home_URL</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">home_URL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">vol</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">source_files</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">text_stream</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">vol</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">pagesets</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="reserved-syntax">cd_pageset</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">vol</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">volume_item</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">vol</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">volumes</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">vol</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="function-syntax">DocumentationCompiler::find_volume</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::find_volume</span></span>:<br/><a href="7-dc.html#SP13_1">&#167;13.1</a>, <a href="7-dc.html#SP13_2">&#167;13.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">title</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">to_match</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">title</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Str::get_first_char</span><span class="plain-syntax">(</span><span class="identifier-syntax">to_match</span><span class="plain-syntax">) == </span><span class="character-syntax">'\"'</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">Str::get_last_char</span><span class="plain-syntax">(</span><span class="identifier-syntax">to_match</span><span class="plain-syntax">) == </span><span class="character-syntax">'\"'</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Str::delete_first_character</span><span class="plain-syntax">(</span><span class="identifier-syntax">to_match</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Str::delete_last_character</span><span class="plain-syntax">(</span><span class="identifier-syntax">to_match</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">V</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">volumes</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Str::eq_insensitive</span><span class="plain-syntax">(</span><span class="identifier-syntax">to_match</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">title</span><span class="plain-syntax">)) || (</span><span class="identifier-syntax">Str::eq_insensitive</span><span class="plain-syntax">(</span><span class="identifier-syntax">to_match</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">label</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">V</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="function-syntax">DocumentationCompiler::home_URL_at_volume_item</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::home_URL_at_volume_item</span></span>:<br/>Documentation Renderer - <a href="7-dr.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">vol</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">vol</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">vol</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">type</span><span class="plain-syntax"> != </span><span class="identifier-syntax">VOLUME_MIT</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">GENERAL_POINTER_IS_NULL</span><span class="plain-syntax">(</span><span class="identifier-syntax">vol</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">user_state</span><span class="plain-syntax">))) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">I</span><span class="string-syntax">"index.html"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cdv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RETRIEVE_POINTER_cd_volume</span><span class="plain-syntax">(</span><span class="identifier-syntax">vol</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">user_state</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">cdv</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">home_URL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="function-syntax">DocumentationCompiler::title_at_volume_item</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::title_at_volume_item</span></span>:<br/>Documentation Renderer - <a href="7-dr.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">vol</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">vol</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">vol</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">type</span><span class="plain-syntax"> != </span><span class="identifier-syntax">VOLUME_MIT</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">GENERAL_POINTER_IS_NULL</span><span class="plain-syntax">(</span><span class="identifier-syntax">vol</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">user_state</span><span class="plain-syntax">))) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">title</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cdv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RETRIEVE_POINTER_cd_volume</span><span class="plain-syntax">(</span><span class="identifier-syntax">vol</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">user_state</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">cdv</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">title</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure cd_volume is accessed in 2/wrk, 2/edt, 2/cps, 2/rqr, 2/jm, 3/bg, 3/is, 4/ebm, 4/km, 4/lm, 4/pm, 4/pbm, 4/pfm, 4/tm, 5/es, 5/ks, 5/ls, 5/ps2, 6/inc, 7/tm, 7/eip, 7/ti, 7/tc, 7/dr, 7/im, 7/mrp and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. </b>A volume contains one or more "pagesets". These are not as simple as pages.
The source may specify multiple source files, and they may each result in
multiple pages.
</p>

<p class="commentary">"Breaking" means dividing up the content into HTML pages by following its
chapter or section structure:
</p>

<pre class="definitions code-font"><span class="definition-keyword">enum</span> <span class="constant-syntax">NO_PAGESETBREAKING</span><span class="plain-syntax"> </span><span class="identifier-syntax">from</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">SECTION_PAGESETBREAKING</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">CHAPTER_PAGESETBREAKING</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">cd_pageset</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">source_specification</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">page_specification</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">nonfile_content</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">breaking</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">cd_pageset</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">cd_pageset</span><span class="plain-syntax"> *</span><span class="function-syntax">DocumentationCompiler::add_page</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::add_page</span></span>:<br/><a href="7-dc.html#SP11">&#167;11</a>, <a href="7-dc.html#SP13_2">&#167;13.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">vol</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">src</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">dest</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">breaking</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">cd_pageset</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pages</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">cd_pageset</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">pages</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">source_specification</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">src</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">pages</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">page_specification</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">dest</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">pages</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">nonfile_content</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">pages</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">breaking</span><span class="plain-syntax"> = </span><span class="identifier-syntax">breaking</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">pages</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_pageset</span><span class="plain-syntax">, </span><span class="identifier-syntax">vol</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">pagesets</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">pages</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure cd_pageset is private to this section.</li></ul>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>"Layout errors" occur when the optional configuration file for a cd contains
syntax errors or asks for something ambiguous or impossible:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">cd_layout_error</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">message</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">line</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">line_number</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">cd_layout_error</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::layout_error</span><button class="popup" onclick="togglePopup('usagePopup8')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup8">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::layout_error</span></span>:<br/><a href="7-dc.html#SP12">&#167;12</a>, <a href="7-dc.html#SP12_2">&#167;12.2</a>, <a href="7-dc.html#SP12_3">&#167;12.3</a>, <a href="7-dc.html#SP13">&#167;13</a>, <a href="7-dc.html#SP13_1">&#167;13.1</a>, <a href="7-dc.html#SP13_2">&#167;13.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">msg</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">line</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_file_position</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tfp</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">cd_layout_error</span><span class="plain-syntax"> *</span><span class="identifier-syntax">err</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">cd_layout_error</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">err</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">message</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">msg</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">err</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">line</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">line</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">err</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">line_number</span><span class="plain-syntax"> = </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">line_count</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">err</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_layout_error</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">layout_errors</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure cd_layout_error is accessed in 5/es, 6/hdn and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b>We respond to such errors by writing a list of them into the documentation's
index page and otherwise not producting documentation at all:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::scold</span><button class="popup" onclick="togglePopup('usagePopup9')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup9">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::scold</span></span>:<br/>Documentation Renderer - <a href="7-dr.html#SP3">&#167;3</a>, <a href="7-dr.html#SP5">&#167;5</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">bad_ones</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">cd_source_file</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cdsf</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">cdsf</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_source_file</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">source_files</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cdsf</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">used</span><span class="plain-syntax"> != </span><span class="constant-syntax">1</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">bad_ones</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">bad_ones</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">HTML_OPEN</span><span class="plain-syntax">(</span><span class="string-syntax">"p"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"No documentation has been produced because the Markdown file(s) "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"provided did not tally:"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">HTML_CLOSE</span><span class="plain-syntax">(</span><span class="string-syntax">"p"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">HTML_OPEN</span><span class="plain-syntax">(</span><span class="string-syntax">"ul"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">cdsf</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_source_file</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">source_files</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cdsf</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">used</span><span class="plain-syntax"> != </span><span class="constant-syntax">1</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">HTML_OPEN</span><span class="plain-syntax">(</span><span class="string-syntax">"li"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"The file '%S' "</span><span class="plain-syntax">, </span><span class="identifier-syntax">cdsf</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">leafname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cdsf</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">used</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"is not part of the layout"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"is ambiguous, matching multiple page-sets in the layout"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">HTML_CLOSE</span><span class="plain-syntax">(</span><span class="string-syntax">"li"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">HTML_CLOSE</span><span class="plain-syntax">(</span><span class="string-syntax">"ul"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">LinkedLists::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">layout_errors</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">HTML_OPEN</span><span class="plain-syntax">(</span><span class="string-syntax">"p"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"No documentation has been produced because the 'contents.txt' or 'sitemap.txt' file was invalid:"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">HTML_CLOSE</span><span class="plain-syntax">(</span><span class="string-syntax">"p"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">HTML_OPEN</span><span class="plain-syntax">(</span><span class="string-syntax">"ul"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">cd_layout_error</span><span class="plain-syntax"> *</span><span class="identifier-syntax">err</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">err</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_layout_error</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">layout_errors</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">HTML_OPEN</span><span class="plain-syntax">(</span><span class="string-syntax">"li"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"Line %d: "</span><span class="plain-syntax">, </span><span class="identifier-syntax">err</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">line_number</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">HTML_OPEN</span><span class="plain-syntax">(</span><span class="string-syntax">"code"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">err</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">line</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">HTML_CLOSE</span><span class="plain-syntax">(</span><span class="string-syntax">"code"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">HTML_TAG</span><span class="plain-syntax">(</span><span class="string-syntax">"br"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">err</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">message</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">HTML_CLOSE</span><span class="plain-syntax">(</span><span class="string-syntax">"li"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">HTML_CLOSE</span><span class="plain-syntax">(</span><span class="string-syntax">"ul"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. </b>"Images" are image files, that is, pictures.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">cd_image</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">source</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">final_leafname</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prefix</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">correct_URL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">used</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">cd_image</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::add_images</span><button class="popup" onclick="togglePopup('usagePopup10')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup10">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::add_images</span></span>:<br/><a href="7-dc.html#SP11">&#167;11</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">pathname</span><span class="plain-syntax"> *</span><span class="identifier-syntax">figures</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prefix</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">L</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Directories::listing</span><span class="plain-syntax">(</span><span class="identifier-syntax">figures</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Platform::is_folder_separator</span><span class="plain-syntax">(</span><span class="identifier-syntax">Str::get_last_char</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">)) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">cd_image</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cdim</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">cd_image</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">cdim</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">source</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Filenames::in</span><span class="plain-syntax">(</span><span class="identifier-syntax">figures</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOOP_THROUGH_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Str::put</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">, </span><span class="identifier-syntax">Characters::tolower</span><span class="plain-syntax">(</span><span class="identifier-syntax">Str::get</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">)));</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">cdim</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">final_leafname</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">cdim</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">correct_URL</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::new</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">prefix</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">cdim</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">correct_URL</span><span class="plain-syntax">, </span><span class="string-syntax">"%S/%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">prefix</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">cdim</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">correct_URL</span><span class="plain-syntax">, </span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">cdim</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">prefix</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">prefix</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">cdim</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">used</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">cdim</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_image</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">images</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Markdown::create</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">link_references</span><span class="plain-syntax">, </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">), </span><span class="identifier-syntax">cdim</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">correct_URL</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd_being_watched_for_image_use</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::watch_image_use</span><button class="popup" onclick="togglePopup('usagePopup11')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup11">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::watch_image_use</span></span>:<br/><a href="7-dc.html#SP21">&#167;21</a><br/>Documentation Renderer - <a href="7-dr.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd_being_watched_for_image_use</span><span class="plain-syntax"> = </span><span class="identifier-syntax">cd</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::notify_image_use</span><span class="plain-syntax">(</span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">URL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cd_being_watched_for_image_use</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">cd_image</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cdim</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">cdim</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_image</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd_being_watched_for_image_use</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">images</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">URL</span><span class="plain-syntax">, </span><span class="identifier-syntax">cdim</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">correct_URL</span><span class="plain-syntax">))</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">cdim</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">used</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure cd_image is accessed in 7/dr and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. </b>And we can now create a new cd object.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="function-syntax">DocumentationCompiler::new_cd</span><button class="popup" onclick="togglePopup('usagePopup12')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup12">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::new_cd</span></span>:<br/><a href="7-dc.html#SP2">&#167;2</a>, <a href="7-dc.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">pathname</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inform_extension</span><span class="plain-syntax"> *</span><span class="identifier-syntax">associated_extension</span><span class="plain-syntax">, </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sitemap</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="7-dc.html#SP11_1" class="named-paragraph-link"><span class="named-paragraph">Initialise the cd structure</span><span class="named-paragraph-number">11.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">cd_source_file</span><span class="plain-syntax"> *</span><span class="identifier-syntax">Documentation_md_cdsf</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="7-dc.html#SP11_2" class="named-paragraph-link"><span class="named-paragraph">Find the possible Markdown source files</span><span class="named-paragraph-number">11.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="7-dc.html#SP11_3" class="named-paragraph-link"><span class="named-paragraph">Read the contents and sitemap files, if they exist</span><span class="named-paragraph-number">11.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><a href="7-dc.html#SP10" class="function-link"><span class="function-syntax">DocumentationCompiler::add_images</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">Pathnames::down</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"Images"</span><span class="plain-syntax">), </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">images_URL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><a href="7-id.html#SP5" class="function-link"><span class="function-syntax">IndexingData::add_default_categories</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">LinkedLists::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">volumes</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">implied</span><span class="plain-syntax"> = </span><a href="7-dc.html#SP6" class="function-link"><span class="function-syntax">DocumentationCompiler::add_volume</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">title</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"index.html"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"Documentation.md"</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax">, </span><span class="identifier-syntax">implied</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">source_files</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">V</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">volumes</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">LinkedLists::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">V</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">source_files</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">            (</span><span class="identifier-syntax">LinkedLists::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">V</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">pagesets</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sf</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">sf</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">source_files</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">dest</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">LinkedLists::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">volumes</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">1</span><span class="plain-syntax">) </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">dest</span><span class="plain-syntax">, </span><span class="string-syntax">"%S_"</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">label</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">dest</span><span class="plain-syntax">, </span><span class="string-syntax">"chapter#.html"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><a href="7-dc.html#SP7" class="function-link"><span class="function-syntax">DocumentationCompiler::add_page</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">sf</span><span class="plain-syntax">, </span><span class="identifier-syntax">dest</span><span class="plain-syntax">, </span><span class="constant-syntax">CHAPTER_PAGESETBREAKING</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">dest</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">cd</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP11_1" class="paragraph-anchor"></a><b>&#167;11.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Initialise the cd structure</span><span class="named-paragraph-number">11.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">title</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::new</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">associated_extension</span><span class="plain-syntax"> = </span><span class="identifier-syntax">associated_extension</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">associated_extension</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">title</span><span class="plain-syntax">, </span><span class="string-syntax">"%X"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">associated_extension</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">as_copy</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">edition</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">work</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">within_extension</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">markdown_content</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">link_references</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Markdown::new_links_dictionary</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">empty</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">examples</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">IFM_example</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cases</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="reserved-syntax">satellite_test_case</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">id</span><span class="plain-syntax"> = </span><a href="7-id.html#SP1" class="function-link"><span class="function-syntax">IndexingData::new_indexing_data</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">examples_lettered</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_URL_pattern</span><span class="plain-syntax"> = </span><span class="identifier-syntax">I</span><span class="string-syntax">"eg_#.html"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">contents_URL_pattern</span><span class="plain-syntax"> = </span><span class="identifier-syntax">I</span><span class="string-syntax">"index.html"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">xrefs_file_pattern</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">manifest_file_pattern</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">index_URL_pattern</span><span class="plain-syntax">[</span><span class="constant-syntax">ALPHABETICAL_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">I</span><span class="string-syntax">"alphabetical_index.html"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">index_URL_pattern</span><span class="plain-syntax">[</span><span class="constant-syntax">NUMERICAL_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">I</span><span class="string-syntax">"numerical_index.html"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">index_URL_pattern</span><span class="plain-syntax">[</span><span class="constant-syntax">THEMATIC_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">I</span><span class="string-syntax">"thematic_index.html"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">index_URL_pattern</span><span class="plain-syntax">[</span><span class="constant-syntax">GENERAL_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">I</span><span class="string-syntax">"general_index.html"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">index_title</span><span class="plain-syntax">[</span><span class="constant-syntax">ALPHABETICAL_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">I</span><span class="string-syntax">"Examples in Alphabetical Order"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">index_title</span><span class="plain-syntax">[</span><span class="constant-syntax">NUMERICAL_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">I</span><span class="string-syntax">"Examples by Number"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">index_title</span><span class="plain-syntax">[</span><span class="constant-syntax">THEMATIC_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">I</span><span class="string-syntax">"Examples by Theme"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">index_title</span><span class="plain-syntax">[</span><span class="constant-syntax">GENERAL_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">I</span><span class="string-syntax">"Index"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">include_index</span><span class="plain-syntax">[</span><span class="constant-syntax">ALPHABETICAL_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">include_index</span><span class="plain-syntax">[</span><span class="constant-syntax">NUMERICAL_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">include_index</span><span class="plain-syntax">[</span><span class="constant-syntax">THEMATIC_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">include_index</span><span class="plain-syntax">[</span><span class="constant-syntax">GENERAL_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">layout_errors</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="reserved-syntax">cd_layout_error</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">volumes</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">compiled_from_extension_scrap</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">duplex_contents_page</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">source_files</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="reserved-syntax">cd_source_file</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">domain</span><span class="plain-syntax"> = </span><span class="identifier-syntax">P</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">images</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="reserved-syntax">cd_image</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">images_URL</span><span class="plain-syntax"> = </span><span class="identifier-syntax">I</span><span class="string-syntax">"images"</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-dc.html#SP11">&#167;11</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP11_2" class="paragraph-anchor"></a><b>&#167;11.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Find the possible Markdown source files</span><span class="named-paragraph-number">11.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">L</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Directories::listing</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Platform::is_folder_separator</span><span class="plain-syntax">(</span><span class="identifier-syntax">Str::get_last_char</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">)) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Str::ends_with</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">".md"</span><span class="plain-syntax">)) || (</span><span class="identifier-syntax">Str::ends_with</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">".MD"</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">cd_source_file</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cdsf</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">cd_source_file</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">cdsf</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">leafname</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">cdsf</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">as_filename</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Filenames::in</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">cdsf</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">used</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">cdsf</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_source_file</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">source_files</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq_insensitive</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"Documentation.md"</span><span class="plain-syntax">))</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">Documentation_md_cdsf</span><span class="plain-syntax"> = </span><span class="identifier-syntax">cdsf</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-dc.html#SP11">&#167;11</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP11_3" class="paragraph-anchor"></a><b>&#167;11.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Read the contents and sitemap files, if they exist</span><span class="named-paragraph-number">11.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">layout_file</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Filenames::in</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"contents.txt"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TextFiles::exists</span><span class="plain-syntax">(</span><span class="identifier-syntax">layout_file</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">TextFiles::read</span><span class="plain-syntax">(</span><span class="identifier-syntax">layout_file</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="string-syntax">"can't open contents file"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">, </span><a href="7-dc.html#SP12" class="function-link"><span class="function-syntax">DocumentationCompiler::read_contents_helper</span></a><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Documentation_md_cdsf</span><span class="plain-syntax">) </span><span class="identifier-syntax">Documentation_md_cdsf</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">used</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sitemap</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">sitemap</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Filenames::in</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"sitemap.txt"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TextFiles::exists</span><span class="plain-syntax">(</span><span class="identifier-syntax">sitemap</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">TextFiles::read</span><span class="plain-syntax">(</span><span class="identifier-syntax">sitemap</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="string-syntax">"can't open sitemap file"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">, </span><a href="7-dc.html#SP13" class="function-link"><span class="function-syntax">DocumentationCompiler::read_sitemap_helper</span></a><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-dc.html#SP11">&#167;11</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::read_contents_helper</span><button class="popup" onclick="togglePopup('usagePopup13')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup13">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::read_contents_helper</span></span>:<br/><a href="7-dc.html#SP11_3">&#167;11.3</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_file_position</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tfp</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">v_cd</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *) </span><span class="identifier-syntax">v_cd</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Str::trim_white_space</span><span class="plain-syntax">(</span><span class="identifier-syntax">cl</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">match_results</span><span class="plain-syntax"> </span><span class="identifier-syntax">mr</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Regexp::create_mr</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *#%c*"</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">Regexp::dispose_of</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">); </span><span class="reserved-syntax">return</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *"</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">Regexp::dispose_of</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">); </span><span class="reserved-syntax">return</span><span class="plain-syntax">; }</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *text: *(%c*?)"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="7-dc.html#SP12_2" class="named-paragraph-link"><span class="named-paragraph">Act on a text declaration</span><span class="named-paragraph-number">12.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *volume: *\"(%c*?)\" or \"(%C+)\""</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="7-dc.html#SP12_1" class="named-paragraph-link"><span class="named-paragraph">Act on a volume declaration</span><span class="named-paragraph-number">12.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *index notation: *(%c*?)"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="7-dc.html#SP12_3" class="named-paragraph-link"><span class="named-paragraph">Act on an indexing notation</span><span class="named-paragraph-number">12.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"unknown syntax in content.txt file"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Regexp::dispose_of</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12_1" class="paragraph-anchor"></a><b>&#167;12.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Act on a volume declaration</span><span class="named-paragraph-number">12.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><a href="7-dc.html#SP6" class="function-link"><span class="function-syntax">DocumentationCompiler::add_volume</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1], </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-dc.html#SP12">&#167;12</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP12_2" class="paragraph-anchor"></a><b>&#167;12.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Act on a text declaration</span><span class="named-paragraph-number">12.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">src</span><span class="plain-syntax"> = </span><span class="identifier-syntax">I</span><span class="string-syntax">"Documentation.md"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">match_results</span><span class="plain-syntax"> </span><span class="identifier-syntax">mr2</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Regexp::create_mr</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr2</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">U</span><span class="string-syntax">"\"(%c*?.md)\""</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">src</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr2</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr2</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">U</span><span class="string-syntax">"\"(%c*?)\""</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"source file must have filename extension '.md'"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"unknown syntax in layout file"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Regexp::dispose_of</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr2</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">slash_count</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">, </span><span class="identifier-syntax">src</span><span class="plain-syntax">) </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Str::get</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">) == </span><span class="character-syntax">'/'</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">Str::get</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">) == </span><span class="character-syntax">'\\'</span><span class="plain-syntax">)) </span><span class="identifier-syntax">slash_count</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">slash_count</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">I</span><span class="string-syntax">"text source cannot contain slash characters"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">star_count_1</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">, </span><span class="identifier-syntax">src</span><span class="plain-syntax">) </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::get</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">) == </span><span class="character-syntax">'*'</span><span class="plain-syntax">) </span><span class="identifier-syntax">star_count_1</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">star_count_1</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">1</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">I</span><span class="string-syntax">"source can contain at most one '*'"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">vol</span><span class="plain-syntax">, *</span><span class="identifier-syntax">last_vol</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">vol</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">volumes</span><span class="plain-syntax">) </span><span class="identifier-syntax">last_vol</span><span class="plain-syntax"> = </span><span class="identifier-syntax">vol</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">last_vol</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">last_vol</span><span class="plain-syntax"> = </span><a href="7-dc.html#SP6" class="function-link"><span class="function-syntax">DocumentationCompiler::add_volume</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">title</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"index.html"</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">LinkedLists::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">source_files</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">counter</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">cd_source_file</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cdsf</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">cdsf</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_source_file</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">source_files</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">cdsf</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">leafname</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">prefix_must_be</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">suffix_must_be</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">star_count_1</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">prefix_must_be</span><span class="plain-syntax">, </span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">src</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0, </span><span class="identifier-syntax">seg</span><span class="plain-syntax">=1; </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">src</span><span class="plain-syntax">); </span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::get_at</span><span class="plain-syntax">(</span><span class="identifier-syntax">src</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">) == </span><span class="character-syntax">'*'</span><span class="plain-syntax">) </span><span class="identifier-syntax">seg</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">seg</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">) </span><span class="identifier-syntax">PUT_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">prefix_must_be</span><span class="plain-syntax">, </span><span class="identifier-syntax">Str::get_at</span><span class="plain-syntax">(</span><span class="identifier-syntax">src</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">));</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">seg</span><span class="plain-syntax"> == </span><span class="constant-syntax">2</span><span class="plain-syntax">) </span><span class="identifier-syntax">PUT_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">suffix_must_be</span><span class="plain-syntax">, </span><span class="identifier-syntax">Str::get_at</span><span class="plain-syntax">(</span><span class="identifier-syntax">src</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Str::begins_with</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">prefix_must_be</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">                (</span><span class="identifier-syntax">Str::ends_with</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">suffix_must_be</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax">, </span><span class="identifier-syntax">last_vol</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">source_files</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">counter</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">cdsf</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">used</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">prefix_must_be</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">suffix_must_be</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">counter</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">I</span><span class="string-syntax">"no Markdown file has a name matching this source"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"Documentation.md"</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax">, </span><span class="identifier-syntax">last_vol</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">source_files</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">src</span><span class="plain-syntax">)</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-dc.html#SP12">&#167;12</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP12_3" class="paragraph-anchor"></a><b>&#167;12.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Act on an indexing notation</span><span class="named-paragraph-number">12.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="7-id.html#SP4" class="function-link"><span class="function-syntax">IndexingData::parse_category_command</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"bad indexing notation"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-dc.html#SP12">&#167;12</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::read_sitemap_helper</span><button class="popup" onclick="togglePopup('usagePopup14')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup14">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::read_sitemap_helper</span></span>:<br/><a href="7-dc.html#SP11_3">&#167;11.3</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_file_position</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tfp</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">v_cd</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *) </span><span class="identifier-syntax">v_cd</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Str::trim_white_space</span><span class="plain-syntax">(</span><span class="identifier-syntax">cl</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">match_results</span><span class="plain-syntax"> </span><span class="identifier-syntax">mr</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Regexp::create_mr</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *#%c*"</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">Regexp::dispose_of</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">); </span><span class="reserved-syntax">return</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *"</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">Regexp::dispose_of</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">); </span><span class="reserved-syntax">return</span><span class="plain-syntax">; }</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *cross-references: to \"(%c*)\""</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">xrefs_file_pattern</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *manifest: to \"(%c*)\""</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">manifest_file_pattern</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *images: to \"(%c*)\""</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">images_URL</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *contents: *(%c+?) to \"(%c*)\""</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">I</span><span class="string-syntax">"standard"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">duplex_contents_page</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">I</span><span class="string-syntax">"duplex"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">duplex_contents_page</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"'contents:' must be 'standard' or 'duplex'"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">contents_URL_pattern</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *examples: *(%c+?) to \"(%c*)\""</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">I</span><span class="string-syntax">"lettered"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">examples_lettered</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">I</span><span class="string-syntax">"numbered"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">examples_lettered</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"'examples:' must be 'lettered' or 'numbered'"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_URL_pattern</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *pages: *(%c*?) *"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="7-dc.html#SP13_2" class="named-paragraph-link"><span class="named-paragraph">Act on a page-set declaration</span><span class="named-paragraph-number">13.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *volume contents: *\"(%c*?)\" to \"(%c*?)\""</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="7-dc.html#SP13_1" class="named-paragraph-link"><span class="named-paragraph">Act on a volume contents declaration</span><span class="named-paragraph-number">13.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *alphabetical index: *\"(%c*?)\" to \"(%c*?)\" *"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">index_title</span><span class="plain-syntax">[</span><span class="constant-syntax">ALPHABETICAL_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">index_URL_pattern</span><span class="plain-syntax">[</span><span class="constant-syntax">ALPHABETICAL_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">include_index</span><span class="plain-syntax">[</span><span class="constant-syntax">ALPHABETICAL_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *numerical index: *\"(%c*?)\" to \"(%c*?)\" *"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">index_title</span><span class="plain-syntax">[</span><span class="constant-syntax">NUMERICAL_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">index_URL_pattern</span><span class="plain-syntax">[</span><span class="constant-syntax">NUMERICAL_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">include_index</span><span class="plain-syntax">[</span><span class="constant-syntax">NUMERICAL_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *thematic index: *\"(%c*?)\" to \"(%c*?)\" *"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">index_title</span><span class="plain-syntax">[</span><span class="constant-syntax">THEMATIC_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">index_URL_pattern</span><span class="plain-syntax">[</span><span class="constant-syntax">THEMATIC_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">include_index</span><span class="plain-syntax">[</span><span class="constant-syntax">THEMATIC_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *general index: *\"(%c*?)\" to \"(%c*?)\" *"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">index_title</span><span class="plain-syntax">[</span><span class="constant-syntax">GENERAL_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">index_URL_pattern</span><span class="plain-syntax">[</span><span class="constant-syntax">GENERAL_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">include_index</span><span class="plain-syntax">[</span><span class="constant-syntax">GENERAL_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"unknown syntax in layout file"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Regexp::dispose_of</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP13_1" class="paragraph-anchor"></a><b>&#167;13.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Act on a volume contents declaration</span><span class="named-paragraph-number">13.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1], </span><span class="identifier-syntax">I</span><span class="string-syntax">"index.html"</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"a volume home page cannot be 'index.html'"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">V</span><span class="plain-syntax"> = </span><a href="7-dc.html#SP6" class="function-link"><span class="function-syntax">DocumentationCompiler::find_volume</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax">) </span><span class="identifier-syntax">V</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">home_URL</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"unknown volume in sitemap file"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-dc.html#SP13">&#167;13</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP13_2" class="paragraph-anchor"></a><b>&#167;13.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Act on a page-set declaration</span><span class="named-paragraph-number">13.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">dest</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">breaking</span><span class="plain-syntax"> = </span><span class="constant-syntax">NO_PAGESETBREAKING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">V</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">set</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0];</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">match_results</span><span class="plain-syntax"> </span><span class="identifier-syntax">mr2</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Regexp::create_mr</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr2</span><span class="plain-syntax">, </span><span class="identifier-syntax">set</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">"(%c*) to \"(%c*?.html)\""</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Str::clear</span><span class="plain-syntax">(</span><span class="identifier-syntax">dest</span><span class="plain-syntax">); </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">dest</span><span class="plain-syntax">, </span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr2</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Str::clear</span><span class="plain-syntax">(</span><span class="identifier-syntax">set</span><span class="plain-syntax">); </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">set</span><span class="plain-syntax">, </span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr2</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr2</span><span class="plain-syntax">, </span><span class="identifier-syntax">set</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">"(%c*) to \"(%c*?)\""</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"destination file must have filename extension '.html'"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr2</span><span class="plain-syntax">, </span><span class="identifier-syntax">set</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">"(%c*) by sections"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">breaking</span><span class="plain-syntax"> = </span><span class="constant-syntax">SECTION_PAGESETBREAKING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Str::clear</span><span class="plain-syntax">(</span><span class="identifier-syntax">set</span><span class="plain-syntax">); </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">set</span><span class="plain-syntax">, </span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr2</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr2</span><span class="plain-syntax">, </span><span class="identifier-syntax">set</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">"(%c*) by chapters"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">breaking</span><span class="plain-syntax"> = </span><span class="constant-syntax">CHAPTER_PAGESETBREAKING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Str::clear</span><span class="plain-syntax">(</span><span class="identifier-syntax">set</span><span class="plain-syntax">); </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">set</span><span class="plain-syntax">, </span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr2</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr2</span><span class="plain-syntax">, </span><span class="identifier-syntax">set</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">"(%c*) by %c*"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"pages may be split only 'by sections' or 'by chapters'"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Str::clear</span><span class="plain-syntax">(</span><span class="identifier-syntax">set</span><span class="plain-syntax">); </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">set</span><span class="plain-syntax">, </span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr2</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::ne_insensitive</span><span class="plain-syntax">(</span><span class="identifier-syntax">set</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"all"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">V</span><span class="plain-syntax"> = </span><a href="7-dc.html#SP6" class="function-link"><span class="function-syntax">DocumentationCompiler::find_volume</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">err</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">err</span><span class="plain-syntax">, </span><span class="string-syntax">"No such volume as '%S': list of known volumes ="</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">volumes</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">err</span><span class="plain-syntax">, </span><span class="string-syntax">" '%S'"</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">title</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">err</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">err</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Regexp::dispose_of</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr2</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">hash_count</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">, </span><span class="identifier-syntax">dest</span><span class="plain-syntax">) </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::get</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">) == </span><span class="character-syntax">'#'</span><span class="plain-syntax">) </span><span class="identifier-syntax">hash_count</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">hash_count</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">breaking</span><span class="plain-syntax"> != </span><span class="constant-syntax">NO_PAGESETBREAKING</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">I</span><span class="string-syntax">"destination must contain a '#' for where the chapter/section number goes"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">hash_count</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">breaking</span><span class="plain-syntax"> == </span><span class="constant-syntax">NO_PAGESETBREAKING</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">I</span><span class="string-syntax">"destination can only contain a '#' when breaking by chapters or sections"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">I</span><span class="string-syntax">"destination can only contain only one '#', and only when breaking by chapters or sections"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">slash_count</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">, </span><span class="identifier-syntax">dest</span><span class="plain-syntax">) </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Str::get</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">) == </span><span class="character-syntax">'/'</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">Str::get</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">) == </span><span class="character-syntax">'\\'</span><span class="plain-syntax">)) </span><span class="identifier-syntax">slash_count</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">slash_count</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">I</span><span class="string-syntax">"no destination filename can (yet) contain slashes"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">star_count_2</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">, </span><span class="identifier-syntax">dest</span><span class="plain-syntax">) </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::get</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">) == </span><span class="character-syntax">'*'</span><span class="plain-syntax">) </span><span class="identifier-syntax">star_count_2</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">star_count_2</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">1</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><a href="7-dc.html#SP8" class="function-link"><span class="function-syntax">DocumentationCompiler::layout_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">I</span><span class="string-syntax">"destination can contain at most one '*'"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cl</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">W</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">volumes</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">V</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> == </span><span class="identifier-syntax">W</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sf</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">sf</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">source_files</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">expanded_dest</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">dest</span><span class="plain-syntax">); </span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::get_at</span><span class="plain-syntax">(</span><span class="identifier-syntax">dest</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">) == </span><span class="character-syntax">'*'</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">j</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">j</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">sf</span><span class="plain-syntax">)-3; </span><span class="identifier-syntax">j</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">                            </span><span class="identifier-syntax">PUT_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">expanded_dest</span><span class="plain-syntax">, </span><span class="identifier-syntax">Str::get_at</span><span class="plain-syntax">(</span><span class="identifier-syntax">sf</span><span class="plain-syntax">, </span><span class="identifier-syntax">j</span><span class="plain-syntax">));</span>

<span class="plain-syntax">                    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">PUT_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">expanded_dest</span><span class="plain-syntax">, </span><span class="identifier-syntax">Str::get_at</span><span class="plain-syntax">(</span><span class="identifier-syntax">dest</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">));</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                </span><a href="7-dc.html#SP7" class="function-link"><span class="function-syntax">DocumentationCompiler::add_page</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">sf</span><span class="plain-syntax">, </span><span class="identifier-syntax">expanded_dest</span><span class="plain-syntax">, </span><span class="identifier-syntax">breaking</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">expanded_dest</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">dest</span><span class="plain-syntax">)</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-dc.html#SP13">&#167;13</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP14" class="paragraph-anchor"></a><b>&#167;14. </b>"Satellite test cases" is an umbrella term including both examples and test
cases, all of which are tested when an extension (say) is tested.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">satellite_test_case</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">is_example</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">IFM_example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">as_example</span><span class="plain-syntax">; </span><span class="comment-syntax"> or </span><span class="extract"><span class="extract-syntax">NULL</span></span><span class="comment-syntax"> for a test case which is not an example</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">owning_heading</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">tree_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">owning_node</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">owner</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">short_name</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">test_file</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ideal_transcript</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">visible_documentation</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">example_errors</span><span class="plain-syntax">; </span><span class="comment-syntax"> of </span><span class="extract"><span class="extract-syntax">markdown_item</span></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">primary_placement</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">secondary_placement</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">satellite_test_case</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">satellite_test_case</span><span class="plain-syntax"> *</span><span class="function-syntax">DocumentationCompiler::new_satellite</span><button class="popup" onclick="togglePopup('usagePopup15')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup15">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::new_satellite</span></span>:<br/><a href="7-dc.html#SP15_1">&#167;15.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">is_eg</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">short_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">F</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">satellite_test_case</span><span class="plain-syntax"> *</span><span class="identifier-syntax">stc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">satellite_test_case</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">is_example</span><span class="plain-syntax"> = </span><span class="identifier-syntax">is_eg</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">as_example</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">owning_heading</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">owning_node</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">owner</span><span class="plain-syntax"> = </span><span class="identifier-syntax">cd</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">short_name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">short_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">test_file</span><span class="plain-syntax"> = </span><span class="identifier-syntax">F</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ideal_transcript</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">visible_documentation</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::new</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_errors</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">primary_placement</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">secondary_placement</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">ideal_leafname</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">ideal_leafname</span><span class="plain-syntax">, </span><span class="string-syntax">"%S-I.txt"</span><span class="plain-syntax">, </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">short_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">IF</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Filenames::in</span><span class="plain-syntax">(</span><span class="identifier-syntax">Filenames::up</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">), </span><span class="identifier-syntax">ideal_leafname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TextFiles::exists</span><span class="plain-syntax">(</span><span class="identifier-syntax">IF</span><span class="plain-syntax">)) </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ideal_transcript</span><span class="plain-syntax"> = </span><span class="identifier-syntax">IF</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">ideal_leafname</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">stc</span><span class="plain-syntax">, </span><span class="reserved-syntax">satellite_test_case</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cases</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">stc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure satellite_test_case is accessed in 5/ks, 7/tm and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. </b>Satellites for a cd consist of examples in the <span class="extract"><span class="extract-syntax">Examples</span></span> subdirectory and
tests in the <span class="extract"><span class="extract-syntax">Tests</span></span> one.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::detect_satellites</span><button class="popup" onclick="togglePopup('usagePopup16')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup16">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::detect_satellites</span></span>:<br/><a href="7-dc.html#SP21">&#167;21</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">domain</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">pathname</span><span class="plain-syntax"> *</span><span class="identifier-syntax">EP</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Pathnames::down</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">domain</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"Examples"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">egs</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="7-dc.html#SP15_1" class="named-paragraph-link"><span class="named-paragraph">Scan EP directory for examples</span><span class="named-paragraph-number">15.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">egs</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EP</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Pathnames::down</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">domain</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"Tests"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="7-dc.html#SP15_1" class="named-paragraph-link"><span class="named-paragraph">Scan EP directory for examples</span><span class="named-paragraph-number">15.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">LinkedLists::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cases</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP15_1" class="paragraph-anchor"></a><b>&#167;15.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Scan EP directory for examples</span><span class="named-paragraph-number">15.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">scan_directory</span><span class="plain-syntax"> *</span><span class="identifier-syntax">D</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Directories::open</span><span class="plain-syntax">(</span><span class="identifier-syntax">EP</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">D</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">leafname</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Directories::next</span><span class="plain-syntax">(</span><span class="identifier-syntax">D</span><span class="plain-syntax">, </span><span class="identifier-syntax">leafname</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">inchar32_t</span><span class="plain-syntax"> </span><span class="identifier-syntax">first</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::get_first_char</span><span class="plain-syntax">(</span><span class="identifier-syntax">leafname</span><span class="plain-syntax">), </span><span class="identifier-syntax">last</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::get_last_char</span><span class="plain-syntax">(</span><span class="identifier-syntax">leafname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Platform::is_folder_separator</span><span class="plain-syntax">(</span><span class="identifier-syntax">last</span><span class="plain-syntax">)) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">first</span><span class="plain-syntax"> == </span><span class="character-syntax">'.'</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">first</span><span class="plain-syntax"> == </span><span class="character-syntax">'('</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">short_name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::new</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">F</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Filenames::in</span><span class="plain-syntax">(</span><span class="identifier-syntax">EP</span><span class="plain-syntax">, </span><span class="identifier-syntax">leafname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Filenames::write_unextended_leafname</span><span class="plain-syntax">(</span><span class="identifier-syntax">short_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">F</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Str::get_at</span><span class="plain-syntax">(</span><span class="identifier-syntax">short_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">short_name</span><span class="plain-syntax">)-2) == </span><span class="character-syntax">'-'</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">                ((</span><span class="identifier-syntax">Str::get_at</span><span class="plain-syntax">(</span><span class="identifier-syntax">short_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">short_name</span><span class="plain-syntax">)-1) == </span><span class="character-syntax">'I'</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                    || (</span><span class="identifier-syntax">Str::get_at</span><span class="plain-syntax">(</span><span class="identifier-syntax">short_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">short_name</span><span class="plain-syntax">)-1) == </span><span class="character-syntax">'i'</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                    || (</span><span class="identifier-syntax">Str::get_at</span><span class="plain-syntax">(</span><span class="identifier-syntax">short_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">short_name</span><span class="plain-syntax">)-1) == </span><span class="character-syntax">'S'</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                    || (</span><span class="identifier-syntax">Str::get_at</span><span class="plain-syntax">(</span><span class="identifier-syntax">short_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">short_name</span><span class="plain-syntax">)-1) == </span><span class="character-syntax">'s'</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">satellite_test_case</span><span class="plain-syntax"> *</span><span class="identifier-syntax">stc</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">                </span><a href="7-dc.html#SP14" class="function-link"><span class="function-syntax">DocumentationCompiler::new_satellite</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">egs</span><span class="plain-syntax">, </span><span class="identifier-syntax">short_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">F</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">is_example</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="named-paragraph-container code-font"><a href="7-dc.html#SP15_1_1" class="named-paragraph-link"><span class="named-paragraph">Scan the example for its header and content</span><span class="named-paragraph-number">15.1.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">leafname</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Directories::close</span><span class="plain-syntax">(</span><span class="identifier-syntax">D</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-dc.html#SP15">&#167;15</a> (twice).</li></ul>
<p class="commentary firstcommentary"><a id="SP16" class="paragraph-anchor"></a><b>&#167;16. </b>Scanning the examples is not a trivial process, because it involves going
through the metadata and also capturing the Markdown material.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">example_scanning_state</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">star_count</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">long_title</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">body_text</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">placement</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">recipe_placement</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">subtitle</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">index</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">desc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">errors</span><span class="plain-syntax">; </span><span class="comment-syntax"> of </span><span class="extract"><span class="extract-syntax">markdown_item</span></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">scanning</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">past_header</span><span class="plain-syntax">;</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">example_scanning_state</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure example_scanning_state is accessed in 5/es, 6/st, 7/tc and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP15_1_1" class="paragraph-anchor"></a><b>&#167;15.1.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Scan the example for its header and content</span><span class="named-paragraph-number">15.1.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">example_scanning_state</span><span class="plain-syntax"> </span><span class="identifier-syntax">ess</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">star_count</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">long_title</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">body_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::new</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">placement</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">recipe_placement</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">subtitle</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">index</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">desc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">errors</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">past_header</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">scanning</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::new</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">scanning</span><span class="plain-syntax">, </span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">Filenames::get_leafname</span><span class="plain-syntax">(</span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">test_file</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">TextFiles::read</span><span class="plain-syntax">(</span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">test_file</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="string-syntax">"unable to read file of example"</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        &amp;</span><a href="7-dc.html#SP18" class="function-link"><span class="function-syntax">DocumentationCompiler::read_example_helper</span></a><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">ess</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">primary</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">secondary</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">vol</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">vol</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">volumes</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">primary</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">primary</span><span class="plain-syntax"> = </span><span class="identifier-syntax">vol</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">secondary</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">secondary</span><span class="plain-syntax"> = </span><span class="identifier-syntax">vol</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">placement</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">primary</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">primary_placement</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">InformFlavouredMarkdown::find_section</span><span class="plain-syntax">(</span><span class="identifier-syntax">primary</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">volume_item</span><span class="plain-syntax">, </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">placement</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">primary_placement</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">err</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::new</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">err</span><span class="plain-syntax">, </span><span class="string-syntax">"example gives Location '%S', which is not the name of any section"</span><span class="plain-syntax">, </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">placement</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><a href="7-dc.html#SP17" class="function-link"><span class="function-syntax">DocumentationCompiler::example_error</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">ess</span><span class="plain-syntax">, </span><span class="identifier-syntax">err</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">recipe_placement</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">secondary</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">secondary_placement</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">InformFlavouredMarkdown::find_section</span><span class="plain-syntax">(</span><span class="identifier-syntax">secondary</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">volume_item</span><span class="plain-syntax">, </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">recipe_placement</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">secondary_placement</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">err</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::new</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">err</span><span class="plain-syntax">, </span><span class="string-syntax">"example gives RecipeLocation '%S', which is not the name of any section"</span><span class="plain-syntax">, </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">recipe_placement</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><a href="7-dc.html#SP17" class="function-link"><span class="function-syntax">DocumentationCompiler::example_error</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">ess</span><span class="plain-syntax">, </span><span class="identifier-syntax">err</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">desc</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><a href="7-dc.html#SP17" class="function-link"><span class="function-syntax">DocumentationCompiler::example_error</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">ess</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">I</span><span class="string-syntax">"example does not give its Description"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">IFM_example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">eg</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InformFlavouredMarkdown::new_example</span><span class="plain-syntax">(</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">long_title</span><span class="plain-syntax">, </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">desc</span><span class="plain-syntax">, </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">star_count</span><span class="plain-syntax">, </span><span class="identifier-syntax">LinkedLists::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">examples</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">eg</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">cue</span><span class="plain-syntax"> = </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">primary_placement</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">eg</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">secondary_cue</span><span class="plain-syntax"> = </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">secondary_placement</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">eg</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">ex_subtitle</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">subtitle</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">eg</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">ex_index</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">index</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">eg</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">primary_label</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">primary</span><span class="plain-syntax">)?(</span><span class="identifier-syntax">primary</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">label</span><span class="plain-syntax">):</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">eg</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">secondary_label</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">secondary</span><span class="plain-syntax">)?(</span><span class="identifier-syntax">secondary</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">label</span><span class="plain-syntax">):</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">eg</span><span class="plain-syntax">, </span><span class="identifier-syntax">IFM_example</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">examples</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">as_example</span><span class="plain-syntax"> = </span><span class="identifier-syntax">eg</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">visible_documentation</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">body_text</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_errors</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ess</span><span class="plain-syntax">.</span><span class="element-syntax">errors</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-dc.html#SP15_1">&#167;15.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP17" class="paragraph-anchor"></a><b>&#167;17. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::example_error</span><button class="popup" onclick="togglePopup('usagePopup17')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup17">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::example_error</span></span>:<br/><a href="7-dc.html#SP15_1_1">&#167;15.1.1</a>, <a href="7-dc.html#SP18">&#167;18</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">example_scanning_state</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ess</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">text</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">err</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::new</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">err</span><span class="plain-syntax">, </span><span class="string-syntax">"Example file '%S': %S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">ess</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">scanning</span><span class="plain-syntax">, </span><span class="identifier-syntax">text</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InformFlavouredMarkdown::error_item</span><span class="plain-syntax">(</span><span class="identifier-syntax">err</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax">, </span><span class="identifier-syntax">ess</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">errors</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP18" class="paragraph-anchor"></a><b>&#167;18. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::read_example_helper</span><button class="popup" onclick="togglePopup('usagePopup18')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup18">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::read_example_helper</span></span>:<br/><a href="7-dc.html#SP15_1_1">&#167;15.1.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">text</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_file_position</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tfp</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">v_state</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">example_scanning_state</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ess</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">example_scanning_state</span><span class="plain-syntax"> *) </span><span class="identifier-syntax">v_state</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tfp</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">line_count</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">match_results</span><span class="plain-syntax"> </span><span class="identifier-syntax">mr</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Regexp::create_mr</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">text</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">"Example *: *(%**) *(%c+?)"</span><span class="plain-syntax">)) ||</span>
<span class="plain-syntax">            (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">text</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">"Example *- *(%**) *(%c+?)"</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">ess</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">star_count</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ess</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">star_count</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><a href="7-dc.html#SP17" class="function-link"><span class="function-syntax">DocumentationCompiler::example_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ess</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">I</span><span class="string-syntax">"this example should be marked (before the title) '*', '**', '***' or '****' for difficulty"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">ess</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">star_count</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ess</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">star_count</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">4</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><a href="7-dc.html#SP17" class="function-link"><span class="function-syntax">DocumentationCompiler::example_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ess</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">I</span><span class="string-syntax">"four stars '****' is the maximum difficulty rating allowed"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">ess</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">star_count</span><span class="plain-syntax"> = </span><span class="constant-syntax">4</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">ess</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">long_title</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><a href="7-dc.html#SP17" class="function-link"><span class="function-syntax">DocumentationCompiler::example_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ess</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">I</span><span class="string-syntax">"titling line of example file is malformed"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Regexp::dispose_of</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ess</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">past_header</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::is_whitespace</span><span class="plain-syntax">(</span><span class="identifier-syntax">text</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">ess</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">past_header</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">; </span><span class="reserved-syntax">return</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">match_results</span><span class="plain-syntax"> </span><span class="identifier-syntax">mr</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Regexp::create_mr</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">text</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">"(%C+?) *: *(%c+?)"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">I</span><span class="string-syntax">"Location"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">ess</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">placement</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">I</span><span class="string-syntax">"RecipeLocation"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">ess</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">recipe_placement</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">I</span><span class="string-syntax">"Subtitle"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">ess</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">subtitle</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">I</span><span class="string-syntax">"Index"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">ess</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">index</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">I</span><span class="string-syntax">"Description"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">ess</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">desc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><a href="7-dc.html#SP17" class="function-link"><span class="function-syntax">DocumentationCompiler::example_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ess</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">I</span><span class="string-syntax">"header line of example file is malformed"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Regexp::dispose_of</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">ess</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">body_text</span><span class="plain-syntax">, </span><span class="string-syntax">"%S\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">text</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP19" class="paragraph-anchor"></a><b>&#167;19. </b>Stage two of sorting out the satellites is to put special items into the
Markdown tree for the cd which mark the places where the examples are referred
to. Note that an example must appear in the primary volume, and can also appear
in the secondary (if there is one).
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::place_example_heading_items</span><button class="popup" onclick="togglePopup('usagePopup19')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup19">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::place_example_heading_items</span></span>:<br/><a href="7-dc.html#SP21">&#167;21</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">satellite_test_case</span><span class="plain-syntax"> *</span><span class="identifier-syntax">stc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">stc</span><span class="plain-syntax">, </span><span class="reserved-syntax">satellite_test_case</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cases</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IFM_example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">eg</span><span class="plain-syntax"> = </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">as_example</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">eg</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">eg_header</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Markdown::new_item</span><span class="plain-syntax">(</span><span class="identifier-syntax">INFORM_EXAMPLE_HEADING_MIT</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">eg</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">header</span><span class="plain-syntax"> = </span><span class="identifier-syntax">eg_header</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">eg_header</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">user_state</span><span class="plain-syntax"> = </span><span class="identifier-syntax">STORE_POINTER_IFM_example</span><span class="plain-syntax">(</span><span class="identifier-syntax">eg</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">primary_placement</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">md</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">markdown_content</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">md</span><span class="plain-syntax">) </span><span class="identifier-syntax">md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">md</span><span class="plain-syntax">) </span><span class="identifier-syntax">md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">md</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax"> = </span><span class="identifier-syntax">eg_header</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">while</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">md</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">)) </span><span class="identifier-syntax">md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">eg_header</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">; </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">eg_header</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">) </span><span class="identifier-syntax">md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">while</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">md</span><span class="plain-syntax">) &amp;&amp; (</span><a href="7-dc.html#SP19" class="function-link"><span class="function-syntax">DocumentationCompiler::skippable_item</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">, </span><span class="identifier-syntax">eg</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">eg_header</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">; </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">eg_header</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>

<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">secondary_placement</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">eg_header</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Markdown::new_item</span><span class="plain-syntax">(</span><span class="identifier-syntax">INFORM_EXAMPLE_HEADING_MIT</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">eg</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">secondary_header</span><span class="plain-syntax"> = </span><span class="identifier-syntax">eg_header</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">eg_header</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">user_state</span><span class="plain-syntax"> = </span><span class="identifier-syntax">STORE_POINTER_IFM_example</span><span class="plain-syntax">(</span><span class="identifier-syntax">eg</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">secondary_placement</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">) </span><span class="identifier-syntax">md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">while</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">md</span><span class="plain-syntax">) &amp;&amp; (</span><a href="7-dc.html#SP19" class="function-link"><span class="function-syntax">DocumentationCompiler::skippable_item</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">, </span><span class="identifier-syntax">eg</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">eg_header</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">; </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">eg_header</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>

<span class="plain-syntax">            </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax">, </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_errors</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Markdown::add_to</span><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">markdown_content</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::skippable_item</span><span class="plain-syntax">(</span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">md</span><span class="plain-syntax">, </span><span class="identifier-syntax">IFM_example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">by</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">md</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">type</span><span class="plain-syntax"> == </span><span class="identifier-syntax">HEADING_MIT</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Markdown::get_heading_level</span><span class="plain-syntax">(</span><span class="identifier-syntax">md</span><span class="plain-syntax">) == </span><span class="constant-syntax">1</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Markdown::get_heading_level</span><span class="plain-syntax">(</span><span class="identifier-syntax">md</span><span class="plain-syntax">) == </span><span class="constant-syntax">2</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">type</span><span class="plain-syntax"> == </span><span class="identifier-syntax">INFORM_EXAMPLE_HEADING_MIT</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IFM_example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">already</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RETRIEVE_POINTER_IFM_example</span><span class="plain-syntax">(</span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">user_state</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">already</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">star_count</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">by</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">star_count</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">already</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">star_count</span><span class="plain-syntax"> &lt; </span><span class="identifier-syntax">by</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">star_count</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::cmp</span><span class="plain-syntax">(</span><span class="identifier-syntax">already</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">name</span><span class="plain-syntax">, </span><span class="identifier-syntax">by</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">name</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP20" class="paragraph-anchor"></a><b>&#167;20. </b>And lastly, we can number the examples. This is done as a third stage of
processing and not as part of the second because we must also pick up
example headers explicitly written in the source text of a single-file extension,
which do not arise from satellites at all.
</p>

<p class="commentary">Once we do know the sequence, we can work out the insignia for each example,
and from that the URL of the HTML file for it.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::count_examples</span><button class="popup" onclick="togglePopup('usagePopup20')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup20">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::count_examples</span></span>:<br/><a href="7-dc.html#SP21">&#167;21</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">example_number</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><a href="7-dc.html#SP20" class="function-link"><span class="function-syntax">DocumentationCompiler::recursively_renumber_examples_r</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">markdown_content</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        &amp;</span><span class="identifier-syntax">example_number</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">examples_lettered</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">IFM_example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">eg</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">eg</span><span class="plain-syntax">, </span><span class="identifier-syntax">IFM_example</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">examples</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Str::clear</span><span class="plain-syntax">(</span><span class="identifier-syntax">eg</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">URL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">i</span><span class="function-syntax">&lt;Str::len(cd-&gt;</span><span class="element-syntax">example_URL_pattern</span><span class="plain-syntax">); </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">inchar32_t</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::get_at</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_URL_pattern</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> == </span><span class="character-syntax">'#'</span><span class="plain-syntax">) </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">eg</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">URL</span><span class="plain-syntax">, </span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">eg</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">insignia</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">PUT_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">eg</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">URL</span><span class="plain-syntax">, </span><span class="identifier-syntax">c</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Markdown::create</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">link_references</span><span class="plain-syntax">, </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">eg</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">name</span><span class="plain-syntax">), </span><span class="identifier-syntax">eg</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">URL</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::recursively_renumber_examples_r</span><span class="plain-syntax">(</span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">md</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> *</span><span class="identifier-syntax">example_number</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">lettered</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">type</span><span class="plain-syntax"> == </span><span class="identifier-syntax">INFORM_EXAMPLE_HEADING_MIT</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IFM_example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RETRIEVE_POINTER_IFM_example</span><span class="plain-syntax">(</span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">user_state</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">md</span><span class="plain-syntax"> == </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">header</span><span class="plain-syntax">) { </span><span class="comment-syntax"> only look at the primary header</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Str::clear</span><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">insignia</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax"> = ++(*</span><span class="identifier-syntax">example_number</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">lettered</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">26</span><span class="plain-syntax">) { </span><span class="identifier-syntax">P</span><span class="plain-syntax"> += </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">N</span><span class="plain-syntax"> -= </span><span class="constant-syntax">26</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">1</span><span class="plain-syntax">) </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">insignia</span><span class="plain-syntax">, </span><span class="string-syntax">"%d"</span><span class="plain-syntax">, </span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">insignia</span><span class="plain-syntax">, </span><span class="string-syntax">"%c"</span><span class="plain-syntax">, </span><span class="character-syntax">'A'</span><span class="plain-syntax">+</span><span class="identifier-syntax">N</span><span class="plain-syntax">-1);</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">insignia</span><span class="plain-syntax">, </span><span class="string-syntax">"%d"</span><span class="plain-syntax">, </span><span class="identifier-syntax">N</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ch</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">; </span><span class="identifier-syntax">ch</span><span class="plain-syntax">; </span><span class="identifier-syntax">ch</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><a href="7-dc.html#SP20" class="function-link"><span class="function-syntax">DocumentationCompiler::recursively_renumber_examples_r</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ch</span><span class="plain-syntax">, </span><span class="identifier-syntax">example_number</span><span class="plain-syntax">, </span><span class="identifier-syntax">lettered</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP21" class="paragraph-anchor"></a><b>&#167;21. </b>We are finally in a position to write <span class="extract"><span class="extract-syntax">DocumentationCompiler::compile_inner</span></span>,
the function which all cd compilations funnel through.
</p>

<p class="commentary">What makes this such a complicated dance is that we need to perform Phase I
Markdown parsing on the examples and the volumes first, in order to get the
necessary links to populate the link references dictionary, and only then
perform Phase II on everything.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::compile_inner</span><button class="popup" onclick="togglePopup('usagePopup21')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup21">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::compile_inner</span></span>:<br/><a href="7-dc.html#SP2">&#167;2</a>, <a href="7-dc.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="7-dc.html#SP10" class="function-link"><span class="function-syntax">DocumentationCompiler::watch_image_use</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="comment-syntax"> Phase I parsing</span>
<span class="plain-syntax">    </span><a href="7-dc.html#SP22" class="function-link"><span class="function-syntax">DocumentationCompiler::Phase_I_on_volumes</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="7-dc.html#SP15" class="function-link"><span class="function-syntax">DocumentationCompiler::detect_satellites</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="7-dc.html#SP19" class="function-link"><span class="function-syntax">DocumentationCompiler::place_example_heading_items</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="7-dc.html#SP20" class="function-link"><span class="function-syntax">DocumentationCompiler::count_examples</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">satellite_test_case</span><span class="plain-syntax"> *</span><span class="identifier-syntax">stc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">stc</span><span class="plain-syntax">, </span><span class="reserved-syntax">satellite_test_case</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cases</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IFM_example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">eg</span><span class="plain-syntax"> = </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">as_example</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">eg</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">visible_documentation</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">alt_ecd</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Markdown::parse_block_structure_using_extended</span><span class="plain-syntax">(</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">stc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">visible_documentation</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">link_references</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">InformFlavouredMarkdown::variation</span><span class="plain-syntax">());</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">eg</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">header</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax"> = </span><span class="identifier-syntax">alt_ecd</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><span class="comment-syntax"> Phase II parsing</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Markdown::parse_all_blocks_inline_using_extended</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">markdown_content</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">link_references</span><span class="plain-syntax">, </span><span class="identifier-syntax">InformFlavouredMarkdown::variation</span><span class="plain-syntax">());</span>

<span class="plain-syntax">    </span><span class="comment-syntax"> Indexing</span>
<span class="plain-syntax">    </span><a href="7-il.html#SP4" class="function-link"><span class="function-syntax">IndexLemmas::scan_documentation</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="7-id.html#SP3" class="function-link"><span class="function-syntax">IndexingData::indexing_occurred</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">)) </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">include_index</span><span class="plain-syntax">[</span><span class="constant-syntax">GENERAL_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">LinkedLists::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">examples</span><span class="plain-syntax">) &gt;= </span><span class="constant-syntax">10</span><span class="plain-syntax">) </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">include_index</span><span class="plain-syntax">[</span><span class="constant-syntax">NUMERICAL_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">LinkedLists::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">examples</span><span class="plain-syntax">) &gt;= </span><span class="constant-syntax">20</span><span class="plain-syntax">) </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">include_index</span><span class="plain-syntax">[</span><span class="constant-syntax">ALPHABETICAL_EG_INDEX</span><span class="plain-syntax">] = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><a href="7-dc.html#SP10" class="function-link"><span class="function-syntax">DocumentationCompiler::watch_image_use</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP22" class="paragraph-anchor"></a><b>&#167;22. </b>In addition to regular Phase I parsing of the content in the volumes, we
want to insert <span class="extract"><span class="extract-syntax">VOLUME_MIT</span></span> and <span class="extract"><span class="extract-syntax">FILE_MIT</span></span> items into the tree to mark where
new files and volumes begin.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::Phase_I_on_volumes</span><button class="popup" onclick="togglePopup('usagePopup22')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup22">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::Phase_I_on_volumes</span></span>:<br/><a href="7-dc.html#SP21">&#167;21</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">pathname</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax"> = </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">domain</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">vol</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">vol</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">volumes</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">cd_volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">mark_vol</span><span class="plain-syntax"> = </span><span class="identifier-syntax">vol</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">cd_pageset</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pages</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">pages</span><span class="plain-syntax">, </span><span class="reserved-syntax">cd_pageset</span><span class="plain-syntax">, </span><span class="identifier-syntax">vol</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">pagesets</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">F</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Filenames::in</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="identifier-syntax">pages</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">source_specification</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">TextFiles::write_file_contents</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">, </span><span class="identifier-syntax">F</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">pages</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">nonfile_content</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">, </span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">pages</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">nonfile_content</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::is_whitespace</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="named-paragraph-container code-font"><a href="7-dc.html#SP22_1" class="named-paragraph-link"><span class="named-paragraph">Content was found for this pageset</span><span class="named-paragraph-number">22.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">markdown_content</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">markdown_content</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Markdown::new_item</span><span class="plain-syntax">(</span><span class="identifier-syntax">DOCUMENT_MIT</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">empty</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InformFlavouredMarkdown::number_headings</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">markdown_content</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">MarkdownVariations::assign_URLs_to_headings</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">markdown_content</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">link_references</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP22_1" class="paragraph-anchor"></a><b>&#167;22.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Content was found for this pageset</span><span class="named-paragraph-number">22.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">subtree</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Markdown::parse_block_structure_using_extended</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">link_references</span><span class="plain-syntax">, </span><span class="identifier-syntax">InformFlavouredMarkdown::variation</span><span class="plain-syntax">());</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">subtree</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pages</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">breaking</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">NO_PAGESETBREAKING:</span>
<span class="plain-syntax">                </span><a href="7-dc.html#SP23" class="function-link"><span class="function-syntax">DocumentationCompiler::do_not_divide_tree</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">subtree</span><span class="plain-syntax">, </span><span class="identifier-syntax">pages</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">page_specification</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">SECTION_PAGESETBREAKING:</span>
<span class="plain-syntax">                </span><a href="7-dc.html#SP23" class="function-link"><span class="function-syntax">DocumentationCompiler::divide_tree_by_sections</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">subtree</span><span class="plain-syntax">, </span><span class="identifier-syntax">pages</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">page_specification</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">CHAPTER_PAGESETBREAKING:</span>
<span class="plain-syntax">                </span><a href="7-dc.html#SP24" class="function-link"><span class="function-syntax">DocumentationCompiler::divide_tree_by_chapters</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">subtree</span><span class="plain-syntax">, </span><span class="identifier-syntax">pages</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">page_specification</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">vol_marker</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">mark_vol</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">vol_marker</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Markdown::new_volume_marker</span><span class="plain-syntax">(</span><span class="identifier-syntax">mark_vol</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">title</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">vol_marker</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">user_state</span><span class="plain-syntax"> = </span><span class="identifier-syntax">STORE_POINTER_cd_volume</span><span class="plain-syntax">(</span><span class="identifier-syntax">mark_vol</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">mark_vol</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">volume_item</span><span class="plain-syntax"> = </span><span class="identifier-syntax">vol_marker</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">mark_vol</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">markdown_content</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">markdown_content</span><span class="plain-syntax"> = </span><span class="identifier-syntax">subtree</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">vol_marker</span><span class="plain-syntax">) { </span><span class="identifier-syntax">vol_marker</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">subtree</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">; </span><span class="identifier-syntax">subtree</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax"> = </span><span class="identifier-syntax">vol_marker</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ch</span><span class="plain-syntax"> = </span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">markdown_content</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">while</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">ch</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">ch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">)) </span><span class="identifier-syntax">ch</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">vol_marker</span><span class="plain-syntax">) { </span><span class="identifier-syntax">ch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">vol_marker</span><span class="plain-syntax">; </span><span class="identifier-syntax">ch</span><span class="plain-syntax"> = </span><span class="identifier-syntax">vol_marker</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">ch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">subtree</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-dc.html#SP22">&#167;22</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP23" class="paragraph-anchor"></a><b>&#167;23. </b>The three strategies for breaking up the tree into chapters or sections,
if that's what we were told to do.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::do_not_divide_tree</span><button class="popup" onclick="togglePopup('usagePopup23')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup23">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::do_not_divide_tree</span></span>:<br/><a href="7-dc.html#SP22_1">&#167;22.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tree</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">naming</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">file_marker</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Markdown::new_file_marker</span><span class="plain-syntax">(</span><span class="identifier-syntax">Filenames::from_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">naming</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">file_marker</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">tree</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">; </span><span class="identifier-syntax">tree</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax"> = </span><span class="identifier-syntax">file_marker</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::divide_tree_by_sections</span><button class="popup" onclick="togglePopup('usagePopup24')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup24">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::divide_tree_by_sections</span></span>:<br/><a href="7-dc.html#SP22_1">&#167;22.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tree</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">naming</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">C</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prev_md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, *</span><span class="identifier-syntax">md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">tree</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">; </span><span class="identifier-syntax">md</span><span class="plain-syntax">; </span><span class="identifier-syntax">prev_md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">, </span><span class="identifier-syntax">md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">type</span><span class="plain-syntax"> == </span><span class="identifier-syntax">HEADING_MIT</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">Markdown::get_heading_level</span><span class="plain-syntax">(</span><span class="identifier-syntax">md</span><span class="plain-syntax">) == </span><span class="constant-syntax">1</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">C</span><span class="plain-syntax">++; </span><span class="identifier-syntax">N</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">type</span><span class="plain-syntax"> == </span><span class="identifier-syntax">HEADING_MIT</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">                (</span><span class="identifier-syntax">Markdown::get_heading_level</span><span class="plain-syntax">(</span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">) == </span><span class="constant-syntax">2</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="named-paragraph-container code-font"><a href="7-dc.html#SP23_1" class="named-paragraph-link"><span class="named-paragraph">Divide by section here</span><span class="named-paragraph-number">23.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">prev_md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">; </span><span class="identifier-syntax">md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">type</span><span class="plain-syntax"> == </span><span class="identifier-syntax">HEADING_MIT</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">Markdown::get_heading_level</span><span class="plain-syntax">(</span><span class="identifier-syntax">md</span><span class="plain-syntax">) == </span><span class="constant-syntax">2</span><span class="plain-syntax">))</span>
<span class="plain-syntax">            </span><span class="named-paragraph-container code-font"><a href="7-dc.html#SP23_1" class="named-paragraph-link"><span class="named-paragraph">Divide by section here</span><span class="named-paragraph-number">23.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP23_1" class="paragraph-anchor"></a><b>&#167;23.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Divide by section here</span><span class="named-paragraph-number">23.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">leaf</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">naming</span><span class="plain-syntax">); </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">inchar32_t</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::get_at</span><span class="plain-syntax">(</span><span class="identifier-syntax">naming</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> == </span><span class="character-syntax">'#'</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">C</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">leaf</span><span class="plain-syntax">, </span><span class="string-syntax">"%d_"</span><span class="plain-syntax">, </span><span class="identifier-syntax">C</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">leaf</span><span class="plain-syntax">, </span><span class="string-syntax">"%d"</span><span class="plain-syntax">, </span><span class="identifier-syntax">N</span><span class="plain-syntax">++);</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">PUT_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">leaf</span><span class="plain-syntax">, </span><span class="identifier-syntax">c</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">file_marker</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Markdown::new_file_marker</span><span class="plain-syntax">(</span><span class="identifier-syntax">Filenames::from_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">leaf</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">leaf</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">prev_md</span><span class="plain-syntax">) </span><span class="identifier-syntax">prev_md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">file_marker</span><span class="plain-syntax">; </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">tree</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax"> = </span><span class="identifier-syntax">file_marker</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">file_marker</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-dc.html#SP23">&#167;23</a> (twice).</li></ul>
<p class="commentary firstcommentary"><a id="SP24" class="paragraph-anchor"></a><b>&#167;24. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">DocumentationCompiler::divide_tree_by_chapters</span><button class="popup" onclick="togglePopup('usagePopup25')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup25">Usage of <span class="code-font"><span class="function-syntax">DocumentationCompiler::divide_tree_by_chapters</span></span>:<br/><a href="7-dc.html#SP22_1">&#167;22.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tree</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">naming</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prev_md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, *</span><span class="identifier-syntax">md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">tree</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">; </span><span class="identifier-syntax">md</span><span class="plain-syntax">; </span><span class="identifier-syntax">prev_md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">, </span><span class="identifier-syntax">md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">md</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">type</span><span class="plain-syntax"> == </span><span class="identifier-syntax">HEADING_MIT</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">Markdown::get_heading_level</span><span class="plain-syntax">(</span><span class="identifier-syntax">md</span><span class="plain-syntax">) == </span><span class="constant-syntax">1</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">leaf</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">naming</span><span class="plain-syntax">); </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">inchar32_t</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::get_at</span><span class="plain-syntax">(</span><span class="identifier-syntax">naming</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> == </span><span class="character-syntax">'#'</span><span class="plain-syntax">) </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">leaf</span><span class="plain-syntax">, </span><span class="string-syntax">"%d"</span><span class="plain-syntax">, </span><span class="identifier-syntax">N</span><span class="plain-syntax">++);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">PUT_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">leaf</span><span class="plain-syntax">, </span><span class="identifier-syntax">c</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">file_marker</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Markdown::new_file_marker</span><span class="plain-syntax">(</span><span class="identifier-syntax">Filenames::from_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">leaf</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">leaf</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">prev_md</span><span class="plain-syntax">) </span><span class="identifier-syntax">prev_md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">file_marker</span><span class="plain-syntax">; </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">tree</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax"> = </span><span class="identifier-syntax">file_marker</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">file_marker</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">md</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="7-tc.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-sm.html">1</a></li><li class="progresschapter"><a href="2-gnr.html">2</a></li><li class="progresschapter"><a href="3-bg.html">3</a></li><li class="progresschapter"><a href="4-em.html">4</a></li><li class="progresschapter"><a href="5-es.html">5</a></li><li class="progresschapter"><a href="6-st.html">6</a></li><li class="progresscurrentchapter">7</li><li class="progresssection"><a href="7-tm.html">tm</a></li><li class="progresssection"><a href="7-eip.html">eip</a></li><li class="progresssection"><a href="7-ti.html">ti</a></li><li class="progresssection"><a href="7-tc.html">tc</a></li><li class="progresscurrent">dc</li><li class="progresssection"><a href="7-dr.html">dr</a></li><li class="progresssection"><a href="7-im.html">im</a></li><li class="progresssection"><a href="7-mrp.html">mrp</a></li><li class="progresssection"><a href="7-id.html">id</a></li><li class="progresssection"><a href="7-it.html">it</a></li><li class="progresssection"><a href="7-il.html">il</a></li><li class="progresssection"><a href="7-imn.html">imn</a></li><li class="progresssection"><a href="7-gi.html">gi</a></li><li class="progresssection"><a href="7-ei.html">ei</a></li><li class="progressnext"><a href="7-dr.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

